//Jen Anderson
//CS 362
//Assignment 4
//Randomtestcard.c

//random test for a card other than adventurer

#include <assert.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

//set NOISY_TEST to 1 to remove print output
#define NOISY_TEST 1
//set TEST_REPS to the number of times you want to run the test
#define TEST_REPS 5

void randomTestRemodel()
{
	srand(time(0));
	//CardArray
	int cards[27] = {curse, estate, duchy, province, copper, silver, gold, adventurer, council_room, feast, gardens, mine, remodel, smithy, village, 
			baron, great_hall, minion, steward, tribute, ambassador, cutpurse, embargo, outpost, salvager, sea_hag, treasure_map};	

	//Initialize a new game and new game state
        int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
        struct gameState *game = newGame();
        initializeGame(3, k, 10, game);

	//Card effect variables
	//pick random cards and put one of them in choice1 and one in choice2
	int i = 0;
	int currentPlayer = 0; 
	int choice1 = 0;
	int choice2 = 1;
	int handPos = 0; //set as constant
	int cardChoice1;
	int cardChoice2;

	//Pick 2 random cards values for choice1 and choice2 and make sure the remodel card returns the correct value
	int output;
	int j;
	for(j = 0; j < TEST_REPS; j++)
	{
		//Set random values for choice1 and choice2  
	 	cardChoice1 = cards[rand()%27];
		cardChoice2 = cards[rand()%27];
		game->hand[currentPlayer][choice1] = cards[cardChoice1];
		game->hand[currentPlayer][choice2] = cards[cardChoice2];
		output = zzzremodelcardplay(i, currentPlayer, choice1, choice2, game, handPos);
		if((getCost(game->hand[currentPlayer][choice1]) + 2) > getCost(game->hand[currentPlayer][choice2]))
		{
			if(output == 1)
			{	if(NOISY_TEST == 1)
				{
					printf("The remodel card correctly set the output to %d when the cost of choice1 was %d and the cost of choice2 was %d\n.", 
						output, getCost(game->hand[currentPlayer][choice1]), getCost(game->hand[currentPlayer][choice2]));
				}
				else
				{
					printf("Passed test");
				}
			}	
			else
			{
				if(NOISY_TEST == 1)
				{
					printf("The remodel card correctly set the output to %d when the cost of choice1 was %d and the cost of choice2 was %d\n.", 
						output, getCost(game->hand[currentPlayer][choice1]), getCost(game->hand[currentPlayer][choice2]));
				}
				else
				{
					printf("Failed test");
				}
			}
		}
		else
		{
			if(output == 0)
			{	if(NOISY_TEST == 1)
				{
					printf("The remodel card correctly set the output to %d when the cost of choice1 was %d and the cost of choice2 was %d\n.", 
						output, getCost(game->hand[currentPlayer][choice1]), getCost(game->hand[currentPlayer][choice2]));
				}
				else
				{
					printf("Passed test");
				}
			}	
			else
			{
				if(NOISY_TEST == 1)
				{
					printf("The remodel card correctly set the output to %d when the cost of choice1 was %d and the cost of choice2 was %d\n.", 
						output, getCost(game->hand[currentPlayer][choice1]), getCost(game->hand[currentPlayer][choice2]));
				}
				else
				{
					printf("Failed test");
				}
			}
		}	
	}
}
		
int main(int argc, char *argv[])
{
    randomTestRemodel();
    return 0;
}
